﻿using InventoryIssue.Infrastructrue.Interface;
using Microsoft.AspNetCore.Mvc.Filters;

namespace InventoryIssue.API.Write.Extensions
{
    public class GlobalExceptionFilter : IExceptionFilter
    {
        private readonly ILogger<GlobalExceptionFilter> logger;

        public GlobalExceptionFilter(ILogger<GlobalExceptionFilter> logger)
        {
            this.logger = logger;
        }
        public void OnException(ExceptionContext context)
        {
            logger.LogError("发生全局异常:" + context.Exception.Message);
            context.ExceptionHandled = true;
        }
    }
}
